package com.xkdx.guangguang.fragment.shop;

import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.xkdx.guangguang.module.network.AbsModule;

public class ShopPicModule extends AbsModule {
	public List<String> urls;
	public List<String> webUrlList;
	public List<String> titleList;
	JSONArray backJson;
	JSONObject jsonObj;
	
	public void setUrls(List<String> urls){
		this.urls = urls;
	}
	

	@Override
	public void parseData() throws Exception {

		try {
			jsonObj = (JSONObject) result;
			jsonObj = jsonObj.getJSONObject("Result");
			if(jsonObj != null && "Success".equals(jsonObj.getString("Status"))){
				parserShop(jsonObj);
			}
//			for (int i = 0; i < backJson.length(); i++) {
//				jsonObj = (JSONObject) backJson.get(i);
//				String sortOfAct = jsonObj.getString("Act");
//				if (sortOfAct.equals("getShopListByShopType")) {
//					list = parserShop(jsonObj.getJSONObject("Content"));
//				}
//
//			}
		} catch (Exception e) {
			// to do define a exception include all parseException
			throw e;
		}

	}

	private void parserShop(JSONObject person) throws Exception{
		try {
			urls.clear();
			JSONArray listInfo = person.getJSONArray("ListInfo");
			for (int i = 0; i < listInfo.length(); i++) {
				JSONObject item = listInfo.getJSONObject(i);
				urls.add(item.getString("Pic"));
				webUrlList.add(item.getString("Url"));
				titleList.add(item.getString("Title"));
			}
		} catch (Exception e) {
			throw e;
		}
	}


	public void setWebUrlList(List<String> webUrlList) {
		this.webUrlList = webUrlList;
	}


	public void setTitleList(List<String> titleList) {
		this.titleList = titleList;
	}

	

}
